package com.lsht.system.service.impl.siwei;

import com.lsht.common.utils.uuid.IdUtils;
import com.lsht.system.domain.siwei.SiweiModel;
import com.lsht.system.mapper.siwei.SiweiModelMapper;
import com.lsht.system.service.siwei.SiweiModelService;
import com.lsht.system.util.NullUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * 型号管理Service业务层处理
 *
 * @author zyc
 * @date 2024-08-14
 */
@Service
public class SiweiModelServiceImpl implements SiweiModelService {
    @Autowired
    private SiweiModelMapper siweiModelMapper;

    /**
     * 新增型号管理
     *
     * @param siweiModel 型号管理
     * @return 结果
     */
    @Override
    public int genAdd(SiweiModel siweiModel) {
        siweiModel.setId(IdUtils.simpleUUID());
        siweiModel.setCreateTime(new Date());
        return siweiModelMapper.genAdd(siweiModel);
    }
    /**
     * 删除型号管理信息
     *
     * @param id 型号管理主键
     * @return 结果
     */
    @Override
    public int genDeleteById(List<String> idList) {
        return siweiModelMapper.genDeleteById(idList);
    }
    /**
     * 修改型号管理
     *
     * @param siweiModel 型号管理
     * @return 结果
     */
    @Override
    public int genUpdateById(SiweiModel siweiModel) {
        siweiModel.setUpdateTime(new Date());
        return siweiModelMapper.genUpdateById(siweiModel);
    }
    /**
     * 查询型号管理列表
     *
     * @param siweiModel 型号管理
     * @return 型号管理
     */
    @Override
    public List<SiweiModel> genQueryList(SiweiModel siweiModel) {
        List<String> date = siweiModel.getDate();
        if (NullUtil.isNotNull(date) && date.size() > 0) {
            siweiModel.setBeginTime(date.get(0));
            siweiModel.setEndTime(date.get(1));
        }
        return siweiModelMapper.genQueryList(siweiModel);
    }

    /**
     * 根据id查询型号详情信息
     * @param siweiModel
     * @return
     */
    @Override
    public SiweiModel genQueryById(SiweiModel siweiModel) {
        return siweiModelMapper.genQueryById(siweiModel);
    }
}
